import React, { Component } from "react";

class Formone extends Component {
  username = React.createRef();
  pwd = React.createRef();

  login = () => {
    console.log(this);
    let username = this.username.current.value;
    let pwd = this.pwd.current.value;
    alert(`账号是${username},密码是${pwd}`);
  };
  render() {
    return (
      <>
        <h1>非受控组件</h1>
        <input type="text" placeholder="账号" ref={this.username} /> <br />
        <br />
        <input type="password" placeholder="密码" ref={this.pwd} /> <br />
        <br />
        <button onClick={this.login}>登 录</button>
      </>
    );
  }
}

export default Formone;
